package com.langsin.RecursionDemo;
/**
@Auther: MFM
@Date: 2021/8/16 - 08 - 16 - 18:53 
@version: 1.0
*/

public class Recursion {
    public static int test(int n){
        if (n==1){
            return 1;
        }else {
            return test(n-1)*n;
        }
    }

    public static int sum(int[] arr,int i){
        if (i == 0){
            return arr[0];
        }else {
            return sum(arr,i-1)+arr[i];
        }

    }


    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6,7,8,9,10};
        System.out.println(sum(arr,arr.length-1));
    }
}
